<template>
  <div class="hl-login">
    <van-field v-model="phone" :disabled="loading" size="large" type="tel" left-icon="phone-o" :maxlength="11" clearable autofocus placeholder="请输入手机号"></van-field>
    <van-field v-model="password" type="password" :disabled="loading" size="large" left-icon="certificate" clearable placeholder="请输入密码"> </van-field>
    <div class="hl-login-btn">
      <van-button round block :loading="loading" loading-text="正在登陆..." :disabled="disLogin" type="info" @click="onLogin">立即登录</van-button>
      <van-button round block type="default" :to="{ name: 'Register' }">注 册</van-button>
    </div>
  </div>
</template>
<script>
import mixins from './mixins'
export default {
  mixins: [mixins],
  created() {
    if (this.$store.state.accessToken) {
      //如果有重定向
      const { redirect } = this.$route.query
      if (redirect) this.$router.replace(redirect)
      else this.$router.replace({ name: 'Home' })
    }
  }
}
</script>

<style lang="less" scoped>
.hl-login {
  /deep/.van-icon {
    color: rgb(153, 153, 153);
  }
  /deep/.van-button {
    margin-top: 16px;
  }
  &-btn {
    padding: 0 16px;
  }
}
</style>
